package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DzXiaoqu;
import com.ruoyi.system.service.IDzXiaoquService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 楼盘小区Controller
 * 
 * @author ruoyi
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/system/xiaoqu")
public class DzXiaoquController extends BaseController
{
    @Autowired
    private IDzXiaoquService dzXiaoquService;

    /**
     * 查询楼盘小区列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DzXiaoqu dzXiaoqu)
    {
        startPage();
        List<DzXiaoqu> list = dzXiaoquService.selectDzXiaoquList(dzXiaoqu);
        return getDataTable(list);
    }

    /**
     * 导出楼盘小区列表
     */
    @Log(title = "楼盘小区", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DzXiaoqu dzXiaoqu)
    {
        List<DzXiaoqu> list = dzXiaoquService.selectDzXiaoquList(dzXiaoqu);
        ExcelUtil<DzXiaoqu> util = new ExcelUtil<DzXiaoqu>(DzXiaoqu.class);
        util.exportExcel(response, list, "楼盘小区数据");
    }

    /**
     * 获取楼盘小区详细信息
     */
    @GetMapping(value = "/{xqId}")
    public AjaxResult getInfo(@PathVariable("xqId") Long xqId)
    {
        return AjaxResult.success(dzXiaoquService.selectDzXiaoquByXqId(xqId));
    }

    /**
     * 新增楼盘小区
     */
    @Log(title = "楼盘小区", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DzXiaoqu dzXiaoqu)
    {
        return toAjax(dzXiaoquService.insertDzXiaoqu(dzXiaoqu));
    }

    /**
     * 修改楼盘小区
     */
    @Log(title = "楼盘小区", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DzXiaoqu dzXiaoqu)
    {
        return toAjax(dzXiaoquService.updateDzXiaoqu(dzXiaoqu));
    }

    /**
     * 删除楼盘小区
     */
    @Log(title = "楼盘小区", businessType = BusinessType.DELETE)
	@DeleteMapping("/{xqIds}")
    public AjaxResult remove(@PathVariable Long[] xqIds)
    {
        return toAjax(dzXiaoquService.deleteDzXiaoquByXqIds(xqIds));
    }
}
